package com.papper.common.service.log;

import com.papper.common.bean.log.LogEmail;
import com.papper.common.enums.DataStatusEnum;
import com.papper.common.mapper.log.LogEmailMapper;
import com.papper.common.service.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @Author:Kim
 * @Date:2021-11-19 10:13:25
 * @Description:邮件发送记录
 */
@Service("logEmailService")
public class LogEmailService extends ServiceImpl<LogEmailMapper, LogEmail> {

	/**
	 * 发送邮件
	 *
	 * @param from     the from
	 * @param to       the to
	 * @param title    the title
	 * @param body     the body
	 * @param filePath the file path
	 */
	public void sendEmail(String from, String to, String title, String body, String filePath) {
		LogEmail logEmail = new LogEmail();
		logEmail.setEmailFrom(from);
		logEmail.setEmailTo(to);
		logEmail.setEmailTitle(title);
		logEmail.setEmailContent("text/html;charset=UTF-8");
		logEmail.setEmailBody(body);
		logEmail.setEmailFiles(filePath);
		logEmail.setDataStatus(DataStatusEnum.OPEN.getCode());
		logEmail.setCreateTime(new Date());
		save(logEmail);
		//TODO:发送邮件任务
	}
}